﻿
namespace DatabaseDoc.Connectors.Sql
{
    using System;

    using Microsoft.SqlServer.Management.Smo;

    public static class ScriptingOptionsFactory
    {
        public static ScriptingOptions GetTableScriptingOptions(SqlServerVersion targetServerVersion)
        {
            var scriptingOptions = new ScriptingOptions
                {
                    IncludeHeaders = true,
                    ScriptSchema = true,
                    ScriptData = false,
                    SchemaQualify = true,
                    SchemaQualifyForeignKeysReferences = true,
                    NoCollation = true,                    
                    ClusteredIndexes = true,                         
                    NonClusteredIndexes = false,
                    DriDefaults = true,                    
                    Indexes = false,
                    Triggers = true,
                    FullTextIndexes = false,
                    TargetServerVersion = targetServerVersion
                };

            return scriptingOptions;
        }        

        public static ScriptingOptions GetIndexesScriptingOptions(SqlServerVersion targetServerVersion)
        {
            var scriptingOptions = new ScriptingOptions
                {
                    IncludeHeaders = true,
                    ScriptSchema = true,
                    ScriptData = false,                    
                    SchemaQualify = true,                    
                    NoCollation = true,
                    ClusteredIndexes = true,
                    NonClusteredIndexes = true,
                    Indexes = true,
                    FullTextIndexes = true,
                    TargetServerVersion = targetServerVersion
                };

            return scriptingOptions;
        }

        public static ScriptingOptions GetForeignKeysScriptingOptions(SqlServerVersion targetServerVersion)
        {
            var scriptingOptions = new ScriptingOptions
                {
                    IncludeHeaders = true,
                    ScriptSchema = true,
                    ScriptData = false,
                    SchemaQualifyForeignKeysReferences = true,                    
                    NoCollation = true,
                    ClusteredIndexes = false,
                    NonClusteredIndexes = false,
                    Indexes = false,
                    FullTextIndexes = false,
                    DriForeignKeys = true,
                    DriAllConstraints = true,
                    TargetServerVersion = targetServerVersion
                };

            return scriptingOptions;
        }

        public static ScriptingOptions GetProgrammabilityScriptingOptions(SqlServerVersion targetServerVersion)
        {
            var scriptingOptions = new ScriptingOptions
            {
                IncludeHeaders = true,
                ScriptSchema = true,
                ScriptData = false,
                SchemaQualify = true,                
                NoCollation = true,
                ClusteredIndexes = false,
                NonClusteredIndexes = false,
                Indexes = false,
                FullTextIndexes = false,
                TargetServerVersion = targetServerVersion
            };

            return scriptingOptions;
        }
    }
}
